<?php
/**
 * Created by PhpStorm.
 * User: addd
 * Date: 2020/10/13
 * Time: 15:24
 */
namespace App\Admin\Selectable;

use Encore\Admin\Facades\Admin;
use Encore\Admin\Grid\Filter;
use Encore\Admin\Grid\Selectable;
use App\Models\BusinessTime;

class BusinessTimes extends Selectable
{
    public $model = BusinessTime::class;

    public function make()
    {

        $this->column('id');
        $this->column('start','开始时间')->display(function ($time){
            if ($time>86400-8*3600){
                return '次日'.date('H:i',$time);
            }
            return date('H:i',$time);
        });
        $this->column('end','结束时间')->display(function ($time){
            if ($time>86400-8*3600){
                return '次日'.date('H:i',$time);
            }
            return date('H:i',$time);
        });
        $this->model()->where('store_id', Admin::user()->store_id);

        $this->filter(function (Filter $filter) {
            // 去掉默认的id过滤器
            $filter->disableIdFilter();
        });
    }
}
